<?php

$username="gmod_tools";
$password="djbnr5895d";
$database="gmod_tools";
$host="localhost";

$uname = urldecode($_GET['uname']);
$pass = urldecode($_GET['pass']);
$pass = md5($pass);
$Type = urldecode($_GET['type']);

@mysql_connect($host,$username,$password) or die("Unable to connect to host!");
@mysql_select_db($database) or die("Unable to select database!");

$result=mysql_query("select * from users where Username='".$uname."' AND password='".$pass."'"); 

if(mysql_numrows($result)>0){
$Status = mysql_result($result,0,"Status");
if ($Status == 3) {
if ($Type == "ban") {
	$query="SELECT * FROM banrequests ORDER BY id DESC";
	$result=mysql_query($query);
	$num=mysql_numrows($result);

	if ($num <= 0){
		die("No Ban Requests found!");
		};
		
	if ($num >100){
		$num = 100;
		};
	$i=0;
	while ($i < $num) {

		$Poster = mysql_result($result,$i,"Poster");
		$On = mysql_result($result,$i,"On");
		$Reason = mysql_result($result,$i,"Reason");
		$SteamID = mysql_result($result,$i,"SteamID");

		print($Poster." want to ban ".$On.", ".$SteamID." Reason: ".$Reason."\n");
		$i++;
		};
	}
elseif($Type == "log") {
    $query="SELECT Log FROM log ORDER BY id DESC";
    $result=mysql_query($query);

    $num=mysql_numrows($result);

    if ($num <= 0){
        die("No log entries found!");
        };

    if ($num >100){
        $num = 100;
        };
    $i=0;
    while ($i < $num) {
        $Log = mysql_result($result,$i,"Log");
        print($Log."\n");
        $i++;
        };
}
elseif($Type == "KD"){
	$query="SELECT * FROM users";
    $result=mysql_query($query);
    $num=mysql_numrows($result);
	
    if ($num <= 0){
        die("No users found!");
        };
    $i=0;
    while ($i < $num) {
		$User = mysql_result($result,$i,"Nick");
        $Kills = mysql_result($result,$i,"Kills");
		$Deaths = mysql_result($result,$i,"Deaths");
		if ($Kills == 0 or $Deaths == 0){ $kd = 0;
		} else{
		$kd = $Kills / $Deaths;
		};
        print($User." has ".$kd." K/D"."\n");
        $i++;
        };
	};
	} else {
	print("You have no access to this tool!\n");
	};
}else {
	print("Wrong username or password!\n");
	};
	mysql_close();
?>